<?php

namespace addons\Minerva;

use Yii;
use common\components\Migration;
use common\interfaces\AddonWidget;

/**
 * 升级数据库
 *
 * Class Upgrade
 * @package addons\Minerva
 */
class Upgrade extends Migration implements AddonWidget
{
    /**
     * @var array
     */
    public $versions = [
        '1.0.0',
        '1.0.1',
        '1.0.2',// 默认版本
    ];

    /**
    * @param $addon
    * @return mixed|void
    * @throws \yii\db\Exception
    */
    public function run($addon)
    {
        switch ($addon->version) {
            case '1.0.2' :
//                $this->createTable('{{%minerva_kill}}', [
//                    'id' => "int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键'",
//                    'merchant_id' => "int(11) NULL DEFAULT '1' COMMENT '店铺ID'",
//                    'merchant_name' => "varchar(50) NULL DEFAULT '' COMMENT '店铺名称'",
//                    'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态'",
//                    'created_at' => "int(10) NULL DEFAULT '0' COMMENT '创建时间'",
//                    'updated_at' => "int(10) NULL DEFAULT '0' COMMENT '修改时间'",
//                    'PRIMARY KEY (`id`)'
//                ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='秒杀'");
                $this->addColumn('{{%backend_member}}','one_department', "int(11) NULL COMMENT '一级部门主键'");
                $this->addColumn('{{%backend_member}}','two_department', "int(11) NULL COMMENT '二级部门主键'");
                break;
        }
    }
}